function setUpAddLink(){
	$('#otherSourceAnchor').live('click', function(){
		if(selection.Cell != false){
			addMediaFromOtherSource();
		} else {
			PicBoard.getTranslations(['lang_247_selectCell'], function(data){
				alert(data.payload.lang_247_selectCell);
			});
		}
	});
}


function addMediaFromOtherSource(){
	$.ajax({
		url: PicBoard.baseURL + 'rsrc.php?req=userListFeed', 
		success: function(data) {
			jQuery.facebox(data);
			
			$('.selectableImageSet').bind('click', function(){
				currID = $(this).attr('id').match(/is(\d+)$/i);
				if(currID.length > 0){
					displayImageSet(currID[1]);
				}
			});
		}
	});
}

function displayImageSet(isID){
	$.post(PicBoard.baseURL + 'rsrc.php?req=userImageFeed', {id: isID}, function(data){
			jQuery.facebox(data);
			$('.imageParent').bind('click', function(){
				image = $(this).find('div.imageHolder > img');
				currID = image.attr('id').match(/i(\d+)$/i);
				if(currID.length > 0){
					copyDataToCell(currID[1], image);
				}
			});
		}
	);
}

function copyDataToCell(imgID, imgObject){
	image = $("#" + selection.Cell);
	target = image.parent();
	targetDataObject = target.data('cellObject');
	
	// Copy the image to the cell
	image.html(imgObject.clone());
	newImage = image.children('img');
	newImage.removeAttr('height').removeAttr('width');
	
	resizeImage(target.find('img'), target.find('.cimg'), target.find('.cimg').height());
	targetDataObject.imageID = imgID;
	targetDataObject.image = 'albumimage';
}


PicBoard.addLoadEvent( "setUpAddLink()" );